package com.web.dao;

import com.web.entity.JobApply;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface JobApplyMapper {
    @Delete({
        "delete from APP_USER_JOB_HUNTING",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_USER_JOB_HUNTING (user_id, post, ",
        "work_type, min_salary, ",
        "max_salary, address, ",
        "longitude, latitude, ",
        "edu_id, contact_info, ",
        "experience_work, job_hunting_description, ",
        "duration, share_num, ",
        "is_invalid, is_topping, ",
        "is_review, create_time, ",
        "modify_time, work_status, ",
        "create_by, modify_by)",
        "values (#{userId,jdbcType=VARCHAR}, #{post,jdbcType=VARCHAR}, ",
        "#{workType,jdbcType=INTEGER}, #{minSalary,jdbcType=DECIMAL}, ",
        "#{maxSalary,jdbcType=DECIMAL}, #{address,jdbcType=VARCHAR}, ",
        "#{longitude,jdbcType=VARCHAR}, #{latitude,jdbcType=VARCHAR}, ",
        "#{eduId,jdbcType=VARCHAR}, #{contactInfo,jdbcType=VARCHAR}, ",
        "#{experienceWork,jdbcType=VARCHAR}, #{jobHuntingDescription,jdbcType=VARCHAR}, ",
        "#{duration,jdbcType=INTEGER}, #{shareNum,jdbcType=INTEGER}, ",
        "#{isInvalid,jdbcType=INTEGER}, #{isTopping,jdbcType=INTEGER}, ",
        "#{isReview,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{modifyTime,jdbcType=TIMESTAMP}, #{workStatus,jdbcType=INTEGER}, ",
        "#{createBy,jdbcType=VARCHAR}, #{modifyBy,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(JobApply record);

    int insertSelective(JobApply record);

    @Select({
        "select",
        "id, user_id, post, work_type, min_salary, max_salary, address, longitude, latitude, ",
        "edu_id, contact_info, experience_work, job_hunting_description, duration, share_num, ",
        "is_invalid, is_topping, is_review, create_time, modify_time, work_status, create_by, ",
        "modify_by",
        "from APP_USER_JOB_HUNTING",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    JobApply selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(JobApply record);

    @Update({
        "update APP_USER_JOB_HUNTING",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "post = #{post,jdbcType=VARCHAR},",
          "work_type = #{workType,jdbcType=INTEGER},",
          "min_salary = #{minSalary,jdbcType=DECIMAL},",
          "max_salary = #{maxSalary,jdbcType=DECIMAL},",
          "address = #{address,jdbcType=VARCHAR},",
          "longitude = #{longitude,jdbcType=VARCHAR},",
          "latitude = #{latitude,jdbcType=VARCHAR},",
          "edu_id = #{eduId,jdbcType=VARCHAR},",
          "contact_info = #{contactInfo,jdbcType=VARCHAR},",
          "experience_work = #{experienceWork,jdbcType=VARCHAR},",
          "job_hunting_description = #{jobHuntingDescription,jdbcType=VARCHAR},",
          "duration = #{duration,jdbcType=INTEGER},",
          "share_num = #{shareNum,jdbcType=INTEGER},",
          "is_invalid = #{isInvalid,jdbcType=INTEGER},",
          "is_topping = #{isTopping,jdbcType=INTEGER},",
          "is_review = #{isReview,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP},",
          "work_status = #{workStatus,jdbcType=INTEGER},",
          "create_by = #{createBy,jdbcType=VARCHAR},",
          "modify_by = #{modifyBy,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(JobApply record);

    JobApply getJobById(Integer id);
}